<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js "></script>
    <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
</head>
<body>
    <script>
        function create() {
            $.ajax({
                url:'http://localhost/api/code/create/'+$('#email').val(),
                type:'get',
                data:{
                    //email:$('#email').val(),
                    //password:$('#password').val()
                },
                success:function (result) {
                    alert("验证码发送成功！");
                }
            })

        }
        function register() {
            if($('#email').val()=="" || $('#password').val()=="" || $('#code').val()==""){
                alert("邮箱、密码、验证码不能为空！")
            }else{
                if ($('#password').val() ==$('#ConfirmPassword').val()) {
                    $.ajax({
                        url:'http://localhost/api/user/register/'+$('#email').val()+'/'+$('#password').val()+'/'+$('#code').val(),
                        type:'get',
                        data:{
                            //email:$('#email').val(),
                            //password:$('#password').val()
                        },
                        success:function (res) {
                            if(res){
                                alert("注册成功,请登录！");
                                window.location.href = "login.html";
                            }else{
                                alert("注册失败！")
                            }
                        }
                    })
                }else{
                    alert("密码不一致，请重新输入！")
                }
            }

        }
    </script>

    注册页面<br/>
  <div>
      邮箱：<input type="text" id="email" width="150px"/><br/>
      密码：<input type="password" id="password" width="150px"/><br/>
      确认密码：<input type="password" id="ConfirmPassword" width="150px"/><br/>
      验证码：<input type="text" id="code" width="150px"/> <span style="color: green;" onclick="create()">获取验证码</span><br/>
      <button style="background-color: green;" width="150px" onclick="register()">注册</button><br/>
  </div>

</body>
</html>